home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / PALET2A.ASM < prev    next >
Assembly Source File  |  1988-05-14  |  40KB  |  792 lines

  1.         .XLIST
  2.         PAGE    ,132
  3.         TITLE   PALET2A.ASM
  4.         .LIST
  5. name palet
  6.  
  7. ; Program sets the EGA palette registers from parameters given on the command
  8. ; line.
  9. ; Release 2 of palette.asm by Charles Lazo III.
  10. ; Enhanced, debugged and recompiled by:
  11. ;       Charles Lazo III  [72210,10]  and  Tim Worley  [71336,730]
  12. ;
  13. ; Detail of changes:
  14. ;       'E' switch now traps changes to EGA registers in all display modes
  15. ;       'T' switch added to trap changes to EGA registers in text mode only
  16. ;       'D' parameter added to return EGA registers to default values
  17. ;       'X' switch unchanged (turns off both E and T switches)
  18. ; Entire on-screen usage text rewritten.
  19. ; Current switch status is displayed each time program is called.
  20. ; Switch settings now remain in effect until changed on the command line.
  21.  
  22. ; Release 2a of palette.asm by Lew Paper
  23. ;
  24. ; Detail of changes:
  25. ;       'B' switch now modifies the blink attribute from the starting
  26. ;           intense background.
  27. ;           'B' toggles it from last time palette reset it.
  28. ;           'B+' turns on blinking.
  29. ;           'B-' turns on intense background colors.
  30. ;       'U' switch now modifies underlining from the starting OFF.
  31. ;           'U' toggles it from last time palette reset it, underlining at
  32. ;               the bottom of a character.
  33. ;           'U+' turns on underlining at the bottom of a character.
  34. ;           'U-' turns off underlining.
  35. ;           'U<n>' underlines at row n, where n is decimal.  For an 25 line
  36. ;                display, 0 <= n <= 13.  For a 43 line display, 0 <= n <= 8.
  37. ;       'F' switch now disables palet.  ARCMASTER apparently changes the
  38. ;           mode of an EGA, and palet's resetting makes it unusable.
  39. ;       'N' switch now enables palet again.  Use it if you have disabled
  40. ;           palet with an F switch and want to enable it with no changes.
  41. ;       Changed octal palette values to decimal.
  42. ; All changes are controlled by the variable LP_Version_2A.
  43.  
  44. LP_Version_2A   EQU     1               ; Use Version 3 changes
  45.  
  46. rt              equ     0dh
  47. lf              equ     0ah
  48. of              equ     offset
  49. farr            equ     dword ptr
  50.  
  51.                 IF      LP_Version_2A
  52. no_underline_row EQU    1FH             ; Underline out of display range
  53. blink_on        EQU     1               ; Turn blinking on
  54. blink_off       EQU     0               ; Turn intense background on
  55.  
  56.  
  57.  
  58. BIOS_seg        segment at 40H
  59.  
  60.                 org     63H
  61. addr_6845       label   word            ; Port to select register for 
  62.                                         ; CRT controller
  63.  
  64.                 org     85H
  65. points          label   word            ; Height of character matrix in lines.
  66.                                         ; 25 rows gives points = 14
  67.                                         ; 43 rows gives points = 8
  68.                                         ; 50 rows gives points = 7
  69. BIOS_seg         ends
  70.                 ENDIF                   ; LP_Version_2A
  71.                 code    segment
  72.                 assume  cs:code
  73.                 IF      LP_Version_2A
  74.                 assume  ds:nothing, es:nothing
  75.                                         ;    This line doesn't change the
  76.                                         ; original program.  In either
  77.                                         ; case, all memory references which
  78.                                         ; would normally use DS have a CS
  79.                                         ; override.
  80.                 ENDIF                   ; LP_Version_2A
  81.  
  82.                 org     100h
  83.  
  84. begin:          jmp     start
  85.  
  86. key1            dw      0cadeh          ; key values stored in code to monitor
  87. key2            dw      0d1bah          ;   TSR resident status
  88.  
  89.                 IF      LP_Version_2A
  90. underline_line  DB      no_underline_row
  91.                                         ; Underline row
  92. start_of_EGA_settings EQU (of underline_line)
  93. length_of_EGA_settings EQU ((of old_int_10) - start_of_EGA_settings)
  94. blink_value     DB      blink_off       ; INT 10H BL value for blinking
  95.                 ENDIF                   ; LP_Version_2A
  96. set_values      db      16 dup(0ffh)    ; attribute values to place in palette
  97.  
  98. ; old_int_10 must immediately follow last byte of set_values since its offset
  99. ; is used later to detect overflow
  100.  
  101. old_int_10      dw      ?,?             ; for segment and offset of old int 10h
  102.  
  103. our_call        db      0               ; flag that lets us only change palette
  104.  
  105. set_palette     proc    near
  106.                 inc     es:our_call     ; lets our set palette requests go thru
  107.                 push    bx              ; save registers used
  108.                 push    cx
  109.                 IF      LP_Version_2A
  110.                 push    dx
  111.                 ENDIF                   ; LP_Version_2A
  112.                 push    si
  113.                 mov     cx,16           ; up to 16 palette registers to set
  114.                 mov     si,of set_values; point to new attributes
  115. next_attribute: mov     bx,16           ; compute palette register for attribute
  116.                 sub     bx,cx
  117.                 lodsb                   ; get attribute to set
  118.                 cmp     al,0ffh         ; if ff here, then don't set
  119.                 jne     set_register
  120.                 loop    next_attribute  ; set all specified palette registers
  121.                 jmp     short set_done  ; done
  122. set_register:   mov     bh,al           ; attribute to bh
  123.                 mov     ax,1000h        ; set palette register function
  124.                 int     10h             ; of ROM BIOS video service
  125.                 loop    next_attribute  ; set all specified palette registers
  126.  
  127.                 IF      LP_Version_2A
  128. set_done:
  129.                 mov     bl,blink_value  ; Set blinking through BIOS
  130.                 mov     ax,1003H
  131.                 int     10H
  132.  
  133.                 push    ds              ; Set underlining through direct
  134.                                         ; hardware accesses
  135.                 assume  ds:BIOS_seg     ; Get address of CRT Controller
  136.                 mov     ax,BIOS_seg
  137.                 mov     ds,ax
  138.                 mov     dx,addr_6845    ; Selector port for CRT Controller
  139.                 mov     al,14h          ; Underline register location
  140.                 out     dx,al           ; Select underline register
  141.                 inc     dx              ; Data port for CRT Controller
  142.                 assume  ds:nothing
  143.                 pop     ds
  144.                 mov     al,underline_line
  145.                                         ; location of the underline.  Note
  146.                                         ; that underline off has 1fh, which
  147.                                         ; is usually too big to show
  148.  
  149.                 out     dx,al
  150.                 dec     es:our_call     ; disallow palette register sets
  151.                 pop     si              ; restore registers
  152.                 pop     dx
  153.                 ELSE                    ; LP_Version_2A
  154. set_done:       dec     es:our_call     ; disallow palette register sets
  155.                 pop     si              ; restore registers
  156.                 ENDIF                   ; LP_Version_2A
  157.                 pop     cx
  158.                 pop     bx
  159.                 ret
  160. set_palette     endp
  161.  
  162. graphics        db      0               ; =1 if graphics, =0 if text
  163. exclude         db      0               ; =1 text & graphx mode changes excluded
  164. txt_exclude     db      0               ; =1 text mode changes only excluded
  165.                 IF      LP_Version_2A
  166. palet_off       db      0               ; =1 disable palet entirely
  167.                 ENDIF                   ; LP_Version_2A
  168.  
  169. new_int_10      proc    far             ; routine modifies the int10h interrupt
  170.                 IF      LP_Version_2A
  171.                 cmp     palet_off,1     ; Is palet disabled?
  172.                 je      go_on           ; Yes.  Bypass it.
  173.                 ENDIF                   ; LP_Version_2A
  174.                 cmp     ah,0            ; a mode set request?
  175.                 je      mode_set